//
//  OAuthModel.m
//  WeiBTest
//
//  Created by Zc_zhou on 15/9/14.
//  Copyright (c) 2015年 Apple. All rights reserved.
//

#import "OAuthModel.h"

@implementation OAuthModel
+(instancetype)accountWithDict:(NSDictionary *)dict
{
    OAuthModel *account = [[OAuthModel alloc] init];
    account.access_token = dict[@"access_token"];
    account.expires_in = dict[@"expires_in"];
    account.uid = dict[@"uid"];
    account.created_time = [NSDate date];
    account.name = dict[@"name"];
    return account;
}
//存入沙盒目录时会调用
-(void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.access_token forKey:@"access_token"];
    [aCoder encodeObject:self.expires_in forKey:@"expires_in"];
    [aCoder encodeObject:self.uid forKey:@"uid"];
    [aCoder encodeObject:self.created_time forKey:@"created_time"];
}
//从沙盒取时会调用
-(id)initWithCoder:(NSCoder *)aDecoder
{
    if (self = [super init])
    {
        self.access_token = [aDecoder decodeObjectForKey:@"access_token"];
        self.expires_in = [aDecoder decodeObjectForKey:@"expires_in"];
        self.uid = [aDecoder decodeObjectForKey:@"uid"];
        self.created_time = [aDecoder decodeObjectForKey:@"created_time"];
        
    }
    return self;
}
@end
